package com.aiju.cash.core.api;

import com.aiju.app.callback.HttpCallback;
import com.aiju.common.http.interceptor.HttpFactory;
import com.aiju.widgit.dialog.DialogHelper;

import java.util.HashMap;
import java.util.Map;

import static com.aiju.app.config.ConfigManager.INIT_SERVER_HOST;

/**
 * @author: 佐为
 * @date: 2016-12-06 15:48
 * @version: V1.0
 * @Description: 打印
 */
public class PrintApi extends BaseApi {

    private String print = INIT_SERVER_HOST + "/print/print";
    private String getprintcontent = INIT_SERVER_HOST + "/print/getprintcontent";
    private String updateprintstatus = INIT_SERVER_HOST + "/print/updateprintstatus";

    private HttpFactory instance;

    public PrintApi(DialogHelper dialogHelper) {
        super(dialogHelper);
        instance = HttpFactory.getInstance();
        instance.setDialogHelper(dialogHelper);
    }

    public void setDialogHelper(DialogHelper dialogHelper) {
        instance.setDialogHelper(dialogHelper);
    }

    /**
     * 打印交易接口
     *
     * @param serialNum
     * @param callback
     */
    public void print(String serialNum, HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        map.put("serialNum", serialNum);
        map.put("token", mUser.getToken());
        map.put("storeId", mUser.getStoreId());
        instance.makeProxy().requestPost(print, map, callback);
    }

    /**
     * 获取打印信息接口
     *
     * @param serialNum
     * @param callback
     */
    public void getprintcontent(String serialNum, HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        map.put("serialNum", serialNum);
        map.put("token", mUser.getToken());
        instance.makeProxy().requestPost(getprintcontent, map, callback);
    }


    /**
     * 交易打印状态更新接口
     *
     * @param callback
     */
    public void updateprintstatus(String serialNum, String printNum, String printDate,String printSerial, HttpCallback callback) {
        Map<String, String> map = new HashMap<>();
        map.put("printReceiveStatus", "1");
        map.put("printSendStatus", "1");
        map.put("serialNum", serialNum);
        map.put("printNum", printNum);
        map.put("printOrder", "");
        map.put("printDate", printDate);
        map.put("printSerial", printSerial);
        map.put("token", mUser.getToken());
        instance.makeProxy().requestPost(updateprintstatus, map, callback);
    }

}
